summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-05-04 20:44:02 +0200
committerGitHub <noreply@github.com>2023-05-04 20:44:02 +0200
commit60d54d911efaec19745e0666c550b77ace8f82ca (patch)
tree420e4538b3ceae940d079b1c758354725ea11d51
parentMerge pull request #10156 from v1993/looks-decent-to-me (diff)
parentFix code resize to use word size rather than byte size (diff)
downloadyuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar.gz
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar.bz2
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar.lz
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar.xz
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.tar.zst
yuzu-60d54d911efaec19745e0666c550b77ace8f82ca.zip
-rw-r--r--src/video_core/shader_cache.cpp4
-rw-r--r--src/video_core/shader_environment.cpp16
-rw-r--r--src/video_core/shader_environment.h6
3 files changed, 16 insertions, 10 deletions
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp
index d9482371b..c5213875b 100644
--- a/src/video_core/shader_cache.cpp
+++ b/src/video_core/shader_cache.cpp
@@ -228,14 +228,14 @@ const ShaderInfo* ShaderCache::MakeShaderInfo(GenericEnvironment& env, VAddr cpu
auto info = std::make_unique<ShaderInfo>();
if (const std::optional<u64> cached_hash{env.Analyze()}) {
info->unique_hash = *cached_hash;
- info->size_bytes = env.CachedSize();
+ info->size_bytes = env.CachedSizeBytes();
} else {
// Slow path, not really hit on commercial games
// Build a control flow graph to get the real shader size
Shader::ObjectPool<Shader::Maxwell::Flow::Block> flow_block;
Shader::Maxwell::Flow::CFG cfg{env, flow_block, env.StartAddress()};
info->unique_hash = env.CalculateHash();
- info->size_bytes = env.ReadSize();
+ info->size_bytes = env.ReadSizeBytes();
}
const size_t size_bytes{info->size_bytes};
const ShaderInfo* const result{info.get()};
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp
index 574760f80..c7cb56243 100644
--- a/src/video_core/shader_environment.cpp
+++ b/src/video_core/shader_environment.cpp
@@ -170,15 +170,19 @@ std::optional<u64> GenericEnvironment::Analyze() {
void GenericEnvironment::SetCachedSize(size_t size_bytes) {
cached_lowest = start_address;
cached_highest = start_address + static_cast<u32>(size_bytes);
- code.resize(CachedSize());
+ code.resize(CachedSizeWords());
gpu_memory->ReadBlock(program_base + cached_lowest, code.data(), code.size() * sizeof(u64));
}
-size_t GenericEnvironment::CachedSize() const noexcept {
- return cached_highest - cached_lowest + INST_SIZE;
+size_t GenericEnvironment::CachedSizeWords() const noexcept {
+ return CachedSizeBytes() / INST_SIZE;
}
-size_t GenericEnvironment::ReadSize() const noexcept {
+size_t GenericEnvironment::CachedSizeBytes() const noexcept {
+ return static_cast<size_t>(cached_highest) - cached_lowest + INST_SIZE;
+}
+
+size_t GenericEnvironment::ReadSizeBytes() const noexcept {
return read_highest - read_lowest + INST_SIZE;
}
@@ -187,7 +191,7 @@ bool GenericEnvironment::CanBeSerialized() const noexcept {
}
u64 GenericEnvironment::CalculateHash() const {
- const size_t size{ReadSize()};
+ const size_t size{ReadSizeBytes()};
const auto data{std::make_unique<char[]>(size)};
gpu_memory->ReadBlock(program_base + read_lowest, data.get(), size);
return Common::CityHash64(data.get(), size);
@@ -198,7 +202,7 @@ void GenericEnvironment::Dump(u64 hash) {
}
void GenericEnvironment::Serialize(std::ofstream& file) const {
- const u64 code_size{static_cast<u64>(CachedSize())};
+ const u64 code_size{static_cast<u64>(CachedSizeBytes())};
const u64 num_texture_types{static_cast<u64>(texture_types.size())};
const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())};
const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())};
diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h
index d75987a52..a0f61cbda 100644
--- a/src/video_core/shader_environment.h
+++ b/src/video_core/shader_environment.h
@@ -48,9 +48,11 @@ public:
void SetCachedSize(size_t size_bytes);
- [[nodiscard]] size_t CachedSize() const noexcept;
+ [[nodiscard]] size_t CachedSizeWords() const noexcept;
- [[nodiscard]] size_t ReadSize() const noexcept;
+ [[nodiscard]] size_t CachedSizeBytes() const noexcept;
+
+ [[nodiscard]] size_t ReadSizeBytes() const noexcept;
[[nodiscard]] bool CanBeSerialized() const noexcept;